package datalookin.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.whu.zj.MyApplication;
import com.whu.zj.R;

import java.util.ArrayList;
import java.util.List;

import datalookin.dto.StationDataDto;

/**
 * 获取历史数据
 * Created by Administrator on 2016/3/7.
 */
public class HistoryAdapter extends BaseAdapter {

    List<StationDataDto> history_items = new ArrayList<StationDataDto>();

    public void setHistory_items(List<StationDataDto> history_items) {
        this.history_items = history_items;
    }

    @Override
    public int getCount() {
        return history_items.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (convertView == null)
        {
            viewHolder = new ViewHolder();
            convertView = View.inflate(MyApplication.share(), R.layout.item_historyinfo,null);
            viewHolder.tv_time = (TextView) convertView.findViewById(R.id.id_tv_time);
            viewHolder.tv_value = (TextView) convertView.findViewById(R.id.id_tv_value);
            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        StationDataDto stationDataDto = history_items.get(position);
        viewHolder.tv_time.setText(stationDataDto.getTime());
        viewHolder.tv_value.setText(stationDataDto.getValue());
        return convertView;
    }

    public static class ViewHolder
    {
        public TextView tv_time;
        public TextView tv_value;
    }
}
